home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d5 / rubik.arc / RUBIK.BAS < prev   
Encoding:
BASIC Source File  |  1985-11-08  |  28.3 KB  |  482 lines

  1. 10 KEY OFF:CLS
  2. 20 PRINT"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"
  3. 30 PRINT"░┌───────────────────────────────────┐░"
  4. 40 PRINT"░│                                   │░"
  5. 50 PRINT"░│            2032-A.BAS             │░"
  6. 60 PRINT"░│           RUBIK'S  CUBE           │░"
  7. 70 PRINT"░│                                   │░"
  8. 80 PRINT"░│                                   │░"
  9. 90 PRINT"░│ BROUGHT TO YOU BY THE MEMBERS OF  │░"
  10. 100 PRINT"░│      ▄▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄▄      │░"
  11. 110 PRINT"░│        █   █   █ █     █   █      │░"
  12. 120 PRINT"░│        █   █▄▄▄█ █     █   █      │░"
  13. 130 PRINT"░│        █   █     █     █   █      │░"
  14. 140 PRINT"░│      ▄▄█▄▄ █     █▄▄▄▄ █▄▄▄█      │░"
  15. 150 PRINT"░│                                   │░"
  16. 160 PRINT"░│      International PC Owners      │░"
  17. 170 PRINT"░│                                   │░"
  18. 180 PRINT"░│P.O. Box 10426, Pittsburgh PA 15234│░"
  19. 190 PRINT"░│                                   │░"
  20. 200 PRINT"░└───────────────────────────────────┘░"
  21. 210 PRINT"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"
  22. 220 PRINT
  23. 230 PRINT "       PRESS ANY KEY TO CONTINUE
  24. 240 A$=INKEY$: IF A$="" THEN 240
  25. 250 CLS
  26. 1000 '           ***********************************
  27. 1010 '           ***    RUBIK'S CUBE SIMULATOR   ***     Compliments of
  28. 1020 '           ***         PC MAGAZINE         ***    UTAH BLUE CHIPS
  29. 1030 '           ***         March. 1982         ***   IBM PC Users Group
  30. 1040 '           ***         Karl Koessel        ***
  31. 1050 '           ***                             ***     December 1982
  32. 1060 '           ***********************************
  33. 1070 SCREEN 0,1,0,0'              Text mode,color on,active page,visual page
  34. 1080 COLOR 7,0,1'                 Print white on black.Border on color monitor
  35. 1090 CLS'                         Clear screen
  36. 1100 KEY OFF'                     Turn off soft keys display on line 25
  37. 1110 CLEAR,,2000'                 Clear some work space
  38. 1120 DEFINT A-Z'                 Variables are all integers
  39. 1130 DIM HOLD(20)'               This array has subscripts greater than 10
  40. 1140 GOSUB 4260'                 Read constants
  41. 1150 GOSUB 4680'                 Initialize variables
  42. 1160 GOSUB 4740'                 Display title page
  43. 1170 GOSUB 4830'                 Input color of faces
  44. 1180 GOSUB 1620'                  Get a new cube
  45. 1190 '********************    INPUT ROUTINES    *****************************
  46. 1200 '************   First input, requests a twist or command
  47. 1210 GOSUB 3780'                                Find proper location
  48. 1220 COLOR 23'                                  Blink ...
  49. 1230 PRINT "Enter ";'                           ... beginning of input prompt
  50. 1240 COLOR 7'                                   Normal foreground
  51. 1250 INPUT "a twist or command: ";TWIST$'       Finish prompt, no question mark
  52. 1260 IF TWIST$="" THEN 1210'                    Operator silent? let's ask again
  53. 1270 GOSUB 2880'                               Input received clear input lines
  54. 1280 REQ$=TWIST$'                              Copy input for testing routines
  55. 1290 GOSUB 1840'                               Check for a valid command, if so
  56. 1300 IF D THEN 1210'                           it's done-go back to first input
  57. 1310 GOSUB 1930'                               Else check for a valid twist
  58. 1320 GOTO 1210'                                Loop back for next twist/command
  59. 1330 '************   Second input request ok to proceed
  60. 1340 GOSUB 3780'                                Find proper location
  61. 1350 PRINT "Press [RETURN] to twist the ";'     Begin second input promt
  62. 1360 IF CLRMON THEN COLOR BR(F) ELSE COLOR 1'   Emphasize the ...
  63. 1370 PRINT PLACE$(1,F);'                        ... name of the chosen face
  64. 1380 COLOR 7'                                   Normal foreground
  65. 1390 PRINT " face ";'                           Middle of second input prompt
  66. 1400 IF CLRMON THEN COLOR BR(F) ELSE COLOR 1'   Emphasize the ...
  67. 1410 PRINT DIRECTION$(OSO)'                     ... direction of the twist
  68. 1420 COLOR 7'                                 Normal foreground
  69. 1430 IF CLRMON AND BIG THEN 1450'             Skip spacing?
  70. 1440 PRINT SPC(13)'                           Print spaces on WIDTH 80 display
  71. 1450 PRINT "or enter a new twist or command: ";'Finish second input prompt.
  72. 1460 INPUT "",GO$'         Comma instead of semicolon suppresses question mark!
  73. 1470 GOSUB 2880'                              Input received-clear input lines
  74. 1480 IF GO$="" THEN 1550'                     If blank, go finish twist, else
  75. 1490 REQ$=GO$'                                Copy input for testing routines
  76. 1500 GOSUB 1840'                              Check for a command, if so do it
  77. 1510 ON D GOTO 1340,1340,1340,1340,1530,1340,1340,1340,1550'     and continue accordingly
  78. 1520 GOSUB 1930'                                 else check for a valid twist
  79. 1530 RETURN'                                  Invalid 2nd input, return to 1st
  80. 1540 '*********   If GO$="" then finish the twist !
  81. 1550 GOSUB 3380'                                Finish turning outer circle
  82. 1560 GOSUB 3540'                                Finish turning chosen face
  83. 1570 GOSUB 2920'                                Turn off highlight flags
  84. 1580 GOSUB 3020'                                Update "twists so far'
  85. 1590 GOSUB 2610'                                Print new cube
  86. 1600 RETURN'                                    Return to first input
  87. 1610 '***************   NEW-ING AND HELP SEQUENCES   *************************
  88. 1620 GOSUB 2920'                              Turn off any highlights
  89. 1630 IF CLRMON THEN WIDTH 40:BIG=-1'          Set to WIDTH 40.Set big flag on
  90. 1640 IF NOT BIG AND D=8 THEN RETURN'          HELP is already on the screen
  91. 1650 GOSUB 3810'                              Clear screen, print instructions
  92. 1660 IF D<>8 THEN GOSUB 3630'                 If not HELP, reinitialize cubies
  93. 1670 IF NOT BIG THEN 1710'                    WIDTH 80 display skips waiting
  94. 1680 GOSUB 4040'                              Wait routine for WIDTH 40
  95. 1690 CLS'                                       Clear screen
  96. 1700 GOSUB 4060'                                Print title on line 25
  97. 1710 GOSUB 2310'                                Reprint display
  98. 1720 RETURN' If NEW, return to 1st input. If HELP, return to what you were doing
  99. 1730 '*******************   TURN INPUT INTO UPPER CASE   **********************
  100. 1740 RQ$=""'                                    Blank new (upper case) string
  101. 1750 FOR K=1 TO LEN(REQ$)'                      For each character of input
  102. 1760    RK$=MID$(REQ$,K,1)'                    Set a character
  103. 1770    IF RK$="'" THEN 1790'                   If prime, skip character change
  104. 1780    RK$=CHR$((ASC(RK$) AND 95))'           Change to upper case character
  105. 1790    RQ$=RQ$+RK$'                           Add character to new string
  106. 1800 NEXT
  107. 1810 REQ$=RQ$'                                  Set old string to a new string
  108. 1820 RETURN'                                    All uppercase, ready to check
  109. 1830 '***************   TO CHECK FOR VALID COMMAND   *************************
  110. 1840 GOSUB 1740'                                 Convert input to upper case
  111. 1850 D=0'                                       Valid command flag set to 'no'
  112. 1860 FOR DMI=1 TO 9'                            Check for valid command. if so,
  113. 1870    IF LEFT$(REQ$,LEN(DM$(DMI)))=DM$(DMI) THEN D=DMI' ...set flag to 'yes'
  114. 1880 NEXT
  115. 1890 IF D>0 AND D<4 THEN DM=D-1'                If display type, set type flag
  116. 1900 ON D GOSUB 2610,2610,2610,2400,1620,2230,3060,1630,2370' Do it ...
  117. 1910 RETURN'                                     ... and/or return
  118. 1920 '*******************   TO CHECK FOR VALID TWIST   ***********************
  119. 1930 GOSUB 2920'                     First turn off highlights that may be on
  120. 1940 '********   Then check if 2nd character valid and input length =2 or less
  121. 1950 IF MID$(REQ$,2,1)="" OR MID$(REQ$,2,1)="'" AND LEN(REQ$)<3 THEN 1980
  122. 1960 GOTO 2040'                      Invalid input
  123. 1970 '********   Check first character of input for a valid twist
  124. 1980 F=0'                            Deselect face
  125. 1990 FOR W=1 TO LEN(T$)'             If twist is valid, set F to face number...
  126. 2000    IF LEFT$(REQ$,1)=MID$(T$,W,1) THEN F=W:TWIST$=REQ$' ...and reset TWIST$
  127. 2010 NEXT
  128. 2020 IF F THEN 2120'                If face valid, go to prepare for 2nd input
  129. 2030 '*********   Invalid input
  130. 2040 GOSUB 3780'                    Locate prompt line, print message
  131. 2050 PRINT "Input ";:COLOR 23:PRINT "NOT";:COLOR 7:PRINT " recognized"
  132. 2060 PRINT "    One moment please..."
  133. 2070 GOSUB 2610'                  Reprint display without highlights
  134. 2080 GOSUB 2880'                  Clear input prompt lines Use Skip to resume/
  135. 2090 RETURN'                        Restart input
  136. 2100 '*******************   PREPARE THE SELECTED TWIST ************************
  137. 2110 '*********   Find direction, set offsets for inner & outer circular arrays
  138. 2120 IF MID$(REQ$,2,1)="'" THEN OSO=2:OSI=1 ELSE OSO=0:OSI=5
  139. 2130 '*********   Then, for the outer circle ...
  140. 2140 GOSUB 3220'                    Decode array pointers
  141. 2150 GOSUB 3280'                    Set holding cells, turn highlight flags on
  142. 2160 '**********   Then for the chosen face
  143. 2170 GOSUB 3480'                    Set holding cells, turn highlight flags on
  144. 2180 '**********   Preparation done ...
  145. 2190 IF SKIP THEN 1550'              If SKIP, no 2nd input, go finish twist now
  146. 2200 GOSUB 2610'                    Reprint display with highlights
  147. 2210 GOTO 1340'                      Go to second input
  148. 2220 '*******************   THOSE USING COLOR CAN CHANGE WIDTH   **************
  149. 2230 IF NOT CLRMON THEN 2350'       This routine is for color monitors only
  150. 2240 BIG=NOT BIG'                   Reverse big flag. -1=WIDTH 40, 0=WIDTH 80
  151. 2250 IF BIG THEN WIDTH 40:GOTO 2280'Make the change to WIDTH 40, skip to 1260
  152. 2260 WIDTH 80'                      Make the change to WIDTH 80
  153. 2270 GOSUB 3810'                    For WIDTH 80, print instructions
  154. 2280 GOSUB 2310'                    Display reprinting routine
  155. 2290 RETURN'                        Go to second input
  156. 2300 '*******************   DISPLAY REPRINTING ROUTINE   **********************
  157. 2310 IF BIG THEN  GOSUB 4080'   Input list for WIDTH 40 display
  158. 2320 GOSUB 2410'                Reprint labels or blanks without changing flag
  159. 2330 GOSUB 2610'                Reprint the cube in the new width
  160. 2340 IF NOT BIG THEN GOSUB 3060'Reprint twists so far without adding a twist
  161. 2350 RETURN'                    Return to input
  162. 2360 '*******************   REVERSE SKIP FLAG   *******************************
  163. 2370 SKIP=NOT SKIP'             -1=SKIP ON, 0=SKIP OFF. WHEN ON, PROGRAM SKIPS
  164. 2380 RETURN'                            second input (request to proceed)
  165. 2390 '*******************   LABELS ON/OFF ROUTINE   ***************************
  166. 2400 LABEL = NOT LABEL'         Reverse label flag. -1=LABELS ON, 0=LABELS OFF
  167. 2410 FOR FA=1 TO 6'                                    For each face
  168. 2420     IF BIG THEN LOCATE XBL(FA),YBL(FA):GOTO 2440' Locate for WIDTH 40 or
  169. 2430     LOCATE X(FA)+2,Y(FA)-1'                       Locate under each face &
  170. 2440     IF NOT LABEL GOTO 2480'                       If labels are wanted off
  171. 2450     IF CLRMON THEN COLOR BR(FA) ELSE COLOR 1'     Emphasize (face's color)
  172. 2460     PRINT PLACE$(1,FA);'                          Print name of face
  173. 2470     GOTO 2490'                                    Otherwise...
  174. 2480     PRINT SPC(5);'                                Print blanks over label
  175. 2490 NEXT
  176. 2500 IF NOT BIG THEN 2590'                             WIDTH 80 display is done
  177. 2510 FOR XBL=1 TO 2'                                   `Front' face has pointer
  178. 2520     LOCATE XBL+4,19-XBL'                          between face and label
  179. 2530     IF NOT LABEL THEN GOTO 2560'                  If labels are wanted off
  180. 2540     COLOR BR(3)'                                  Color of front face
  181. 2550     PRINT "/";'                                   Make pointer of slashes
  182. 2560     PRINT " "'                                    or blank out the slashes
  183. 2570 NEXT
  184. 2580 COLOR 7'                                          Normal foreground
  185. 2590 RETURN'                                           To what you were doing
  186. 2600 '*******************   CUBE PRINTING TOURTINE   **************************
  187. 2610 DB=1:DUB=0'                        Initialize display formatting variables
  188. 2620 IF BIG THEN BD=2'                  Double this variable for WIDTH 40
  189. 2630 FOR FA=1 TO 6'                     For each face
  190. 2640 FOR PP=0 TO 8 : P=XOP(PP)'         For each cubie on this face
  191. 2650 IF BIG THEN FOR DUB=0 TO 1'        To square cubie WIDTH 40 prints 2 lines
  192. 2660     LOCATE X(FA)+XOF(P)*DB+DUB-REL(FA)*BIG,Y(FA)+YOF(P)+RELY(FA)*BIG'Where
  193. 2670     BR=BR(FIX(CUBIE(FA,P,1)\10))'                     Set background color
  194. 2680     IF BR THEN COLOR CUBIE(FA,P,2)*-16,BR:GOTO 2700'  Blink foreground?
  195. 2690     IF CUBIE(FA,P,2) THEN COLOR 0,7 ELSE COLOR 7,0'   Turn on highlights?
  196. 2700     IF DUB THEN PRINT "  ";:GOTO 2730'                Bottom half of cubie
  197. 2710     IF DM THEN PRINT USING "\\"; CUBIE$(FA,P,DM);                                         ELSE PRINT USING "##"; CUBIE(FA,P,1);'   Print proper type cubie
  198. 2720 '*************   These lines tidy diplay as colors/highlights change
  199. 2730     ON P+1 GOTO 2750,2740,2740,2820,2820,2820,2760,2760,2750'  Nine cubies
  200. 2740     ND=1:GOTO 2780'                        Set the `NextDoor' variable for
  201. 2750     ND=4:GOTO 2780'                         six of them so following line
  202. 2760     ND=-1:GOTO 2780'                        can compare neighboring cubies
  203. 2770 '                Find proper colors for each side of spaces between cubies
  204. 2780     IF BR THEN COLOR BR,BR(FIX(CUBIE(FA,(P+ND) MOD 12,1)\10)) ELSE 2800
  205. 2790     PRINT CHR$(221);:GOTO 2820'    Left half one color, right half another
  206. 2800     IF CUBIE(FA,P,2)=CUBIE(FA,(P+ND) MOD 12,2) THEN 2810 ELSE COLOR 7,0
  207. 2810     PRINT " ";'                    Single space lit or not, for monochrome
  208. 2820 IF BIG THEN NEXT '                 WIDTH 40 prints 2 lines to square cubie
  209. 2830     NEXT
  210. 2840 NEXT
  211. 2850 COLOR 7,0'                                NormalizeFOREGROUND, BACKGROUND/
  212. 2860 RETURN
  213. 2870 '*******************   CLEAR PROMPT/INPUT LINES   ************************
  214. 2880 GOSUB 3780'                     Find proper location (differs on WIDTH 40)
  215. 2890 PRINT "One moment, please..."SPC(79)SPC(39)SPC(21)'   Clears lines 15 & 16
  216. 2900 RETURN'                               If WIDTH 40 clears lines 19, 20 & 21
  217. 2910 '*******************   TURN OFF HIGHLIGHT FLAGS   ************************
  218. 2920 FOR J=1 TO 4'                Four faces touch the chosen face and have ...
  219. 2930     FOR K=1 TO 3'            Three consecutive cubies touching chosen face
  220. 2940         CUBIE(FACE(J),((POSITION(J)+K-2) MOD 8)+1,2)=0'  Turn highlight...
  221. 2950     NEXT'                                                   ...flags `off'
  222. 2960 NEXT
  223. 2970 FOR P=1 TO 8'                All cubies on chosen face except the center
  224. 2980     CUBIE(F,P,2)=0'          Turn highlight flags `off'
  225. 2990 NEXT
  226. 3000 RETURN
  227. 3010 '*******************   KEEP TRACK OF TWISTS   ****************************
  228. 3020 TWISTSSOFAR$(AT)=TWISTSSOFAR$(AT)+TWIST$+" "'   Add valid twist to records
  229. 3030 IF LEN(TWISTSSOFAR$(AT))>36 THEN AT=AT+1'  Keeps 2 letter twists on 1 line
  230. 3040 IF BIG THEN  RETURN'                       WIDTH 40 doesn't print new list
  231. 3050 '*******************   PRINT LIST OF TWISTS SO FAR   *********************
  232. 3060 LOCATE 18,1'                               Begin at bottom third of screen
  233. 3070 IF BIG THEN PRINT '                        Down 1 more line for WIDTH 40
  234. 3080 COLOR 1'                                   Enphasize list of twists header
  235. 3090 PRINT TWISTSSOFAR$(0);'                    Print header
  236. 3100 COLOR 7'                                   Normal foreground
  237. 3110 PRINT SPC(13)'                             Put space between header & list
  238. 3120 FOR K=1 TO AT'                             For each half line of twists
  239. 3130     PRINT TWISTSSOFAR$(K);'                Print 1st half line. If not big
  240. 3140     IF NOT BIG THEN PRINT TWISTSSOFAR$(K+1);:K=K+1'    Print 2nd half line
  241. 3150     PRINT'                                 Linefeed before end of WIDTH
  242. 3160 NEXT
  243. 3170 IF NOT BIG THEN RETURN'                    If WIDTH 80, all done, return
  244. 3180 GOSUB 4040'                                For WIDTH 40, wait to continue,
  245. 3190 GOSUB 2880'                                clear input rpompt lines,
  246. 3200 RETURN'                                    then return
  247. 3210 '*******************   DECODE ARRAY POINTERS FOR OUTER CIRCLE   **********
  248. 3220 FOR J=1 TO 4'                             Four faces touch any chosen face
  249. 3230     FACE(J)=VAL(MID$(OC$(F),J*2-1,1))'    Which four? Also, from each, the
  250. 3240     POSITION(J)=VAL(MID$(OC$(F),J*2,1))'  first of the three consecutive
  251. 3250 NEXT '                                    cubies closest to a chosen face
  252. 3260 RETURN
  253. 3270 '*******************   PREPARE TO TURN OUTER CIRCLE   ********************
  254. 3280 FOR J=1 TO 4'                             Four faces touch chosen face...
  255. 3290     FOR K=1 TO 3'                         ...with three consecutive cubies
  256. 3300 '                                         Set cubie value in holding cell
  257. 3310         HOLD((J-1)*3+K)=CUBIE(FACE(J),((POSITION(J)+K-2) MOD 8)+1,1)
  258. 3320 '                                         Turn highlight flags `on'
  259. 3330         CUBIE(FACE(J),((POSITION(J)+K-2) MOD 8)+1,2)=-1
  260. 3340     NEXT
  261. 3350 NEXT
  262. 3360 RETURN
  263. 3370 '*******************   FINISH TURNING OUTER CIRCLE   *********************
  264. 3380 FOR J=1 TO 4'                             Four faces touch chosen face...
  265. 3390     FOR K=1 TO 3'                         ...with three consecutive cubies
  266. 3400         CUBIE(FACE(((J+OSO) MOD 4)+1),((POSITION(((J+OSO) MOD 4)+1)+K-2)             MOD 8)+1,1)=HOLD((J-1)*3+K)'               New value of each cubie
  267. 3410         FOR DMI=1 TO 2'                            Associated names follow
  268. 3420         CUBIE$(FACE(((J+OSO) MOD 4)+1),((POSITION(((J+OSO) MOD 4)+1)             +K-2) MOD 8)+1,DMI)=PLACE$(DMI,FIX((HOLD((J-1)*3+K)\10)))
  269. 3430         NEXT
  270. 3440     NEXT
  271. 3450 NEXT
  272. 3460 RETURN
  273. 3470 '*******************   PREPARE TO TURN CHOSEN FACE   *********************
  274. 3480 FOR P=1 TO 8'                  All cubies on chosen face except the center
  275. 3490     HOLD(12+P)=CUBIE(F,P,1)'               Put cubie value in holding cell
  276. 3500     CUBIE(F,P,2)=-1'                       Turn highlight flags `on'
  277. 3510 NEXT
  278. 3520 RETURN
  279. 3530 '*******************   FINISH TURNING THE CHOSEN FACE   ******************
  280. 3540 FOR P=1 TO 8'                  All cubies on chosen face except the center
  281. 3550     CUBIE(F,P,1)=HOLD(13+((P+OSI) MOD 8))'          New value of each cubi
  282. 3560     FOR DMI=1 TO 2'                                Associated names follow
  283. 3570         CUBIE$(F,P,DMI)=PLACE$(DMI,FIX(CUBIE(F,P,1)\10))
  284. 3580     NEXT
  285. 3590 NEXT
  286. 3600 RETURN
  287. 3610 '*******************   SET UP FRESH CUBE   *******************************
  288. 3620 'Initialize cubie array to starting values
  289. 3630 FOR F=1 TO 6'                                    Six faces on the cube
  290. 3640     FOR P=0 TO 9'                                Nine cubies per face
  291. 3650         CUBIE(F,P,1)=F*10+P'                     Two digit code
  292. 3660         FOR DMI=1 TO 2'                          Associated face ond color
  293. 3670         CUBIE$(F,P,DMI)=LEFT$(PLACE$(DMI,F),2)
  294. 3680         NEXT
  295. 3690     NEXT
  296. 3700 NEXT
  297. 3710 'Erase accumulated `twists so far'
  298. 3720 FOR K=1 TO AT
  299. 3730     TWISTSSOFAR$(K)=""'                          Erase each line
  300. 3740 NEXT
  301. 3750 AT=1'                                            Begin line index at 1
  302. 3760 RETURN
  303. 3770 '*******************   WIDTH 40 PROMPT LINE RELOCATER   ******************
  304. 3780 IF BIG THEN LOCATE 19,1 ELSE LOCATE 15,1'        Location of input prompt
  305. 3790 RETURN
  306. 3800 '*******************   CLEAR SCREEN, PRINT INSTRUCTIONS   ****************
  307. 3810 IF BIG THEN COLOR ,4:BG=3 ELSE BG=43'      Set background color, offsets
  308. 3820 CLS'                                       Clear screen
  309. 3830 LOCATE 1,1+BG:COLOR 1:PRINT TITLES$'       Use emphasis where needed
  310. 3840 LOCATE 3,3+BG:COLOR 7:PRINT "Each twist is called by the first"
  311. 3850 LOCATE 4,BG:PRINT "letter of the face you wish to twist:"
  312. 3860 LOCATE 5,BG:COLOR 1:PRINT "U";:COLOR 7:PRINT " for the upper face, ";           :COLOR 1:PRINT "L";:COLOR 7:PRINT " for the left"
  313. 3870 LOCATE 6,BG:PRINT "face, ";:COLOR 1:PRINT "F";:COLOR 7:                         :PRINT " for the front face, ";:COLOR 1:PRINT "R";:COLOR 7:PRINT" for the"
  314. 3880 LOCATE 7,BG:PRINT "right face, ";:COLOR 1:PRINT "B";:COLOR 7                    :PRINT " for the back face and ";:COLOR 1:PRINT "D":COLOR 7
  315. 3890 LOCATE 8,BG:PRINT "for the downward face. The twists will"
  316. 3900 LOCATE 9,BG:PRINT "be clockwise. To make a counterclock-"
  317. 3910 LOCATE 10,BG:PRINT "wise twist, the letter is followed by"
  318. 3920 LOCATE 11,BG:PRINT "a ";:COLOR 1:PRINT "'";:COLOR 7:PRINT " (e.g. ";            :COLOR 1:PRINT "L'";:COLOR 7:PRINT " ). To change the display,"
  319. 3930 LOCATE 12,BG:PRINT "enter either the word ";:COLOR 1:PRINT "Labels";            :COLOR 7:PRINT " or ";:COLOR 1:PRINT "Colors";:COLOR 7
  320. 3940 IF CLRMON THEN LOCATE 12,BG:PRINT "enter the word ";:COLOR 1:PRINT "Big";:                     COLOR 7:PRINT" or ";'Additional commands for color monitors
  321. 3950 LOCATE 13,BG:PRINT "or ";:COLOR 1:PRINT "Faces";:COLOR 7:PRINT " or ";          :COLOR 1:PRINT"Codes";:COLOR 7:PRINT". Use ";:COLOR 1:PRINT "Skip";:COLOR 7     :PRINT " to resume/"
  322. 3960 LOCATE 14,BG:PRINT "skip verification. Use ";:COLOR 1:PRINT "New";:COLOR 7      :PRINT " to restart."
  323. 3970 IF NOT BIG THEN RETURN'            The following commands are for WIDTH 40
  324. 3980 LOCATE 15,3:PRINT "To accommodate those using television ";
  325. 3990 PRINT "  sets (i.e. confined to WIDTH 40), the ";
  326. 4000 PRINT "  commands ";:COLOR 1:PRINT "List";:COLOR 7:PRINT " & ";:COLOR 1
  327. 4010 PRINT "Help";:COLOR 7:PRINT " have been added."
  328. 4020 RETURN
  329. 4030 '*******************   WAIT TO CONTINUE   ********************************
  330. 4040 LOCATE 25,9:PRINT "Press the spacebar to continue";
  331. 4050 IF INKEY$<>" " THEN 4050
  332. 4060 LOCATE 25,3:COLOR 1,4:PRINT TITLE$;:COLOR 7,0:RETURN
  333. 4070 '*******************   WIDTH 40 INPUT LIST   *****************************
  334. 4080 LOCATE 1,19:COLOR BR(2),,BR(4):PRINT "Twists: ";
  335. 4090 FOR LI=1 TO 2:LOCATE LI,25+LI
  336. 4100     FOR TI=1 TO 3
  337. 4110         FOR DI=0 TO 1
  338. 4120         COLOR BR((LI-1)*3+TI)
  339. 4130         IF DI THEN PU$="!' " ELSE PU$="! "
  340. 4140         PRINT USING PU$;MID$(T$,(LI-1)*3+TI);
  341. 4150         NEXT
  342. 4160     NEXT
  343. 4170 NEXT
  344. 4180 LOCATE 4,31:COLOR BR(6):PRINT "Commands:";
  345. 4190 FOR CM=1 TO 9
  346. 4200     LOCATE 5+CM,35
  347. 4210     COLOR BR(CM MOD 6+1)
  348. 4220     PRINT DM$(CM)
  349. 4230 NEXT
  350. 4240 COLOR 7:RETURN
  351. 4250 '*******************   READ CONSTANTS   **********************************
  352. 4260 FOR FACE=1 TO 6'                 Six faces
  353. 4270     READ PLACE$(1,FACE)'        Name and number each face
  354. 4280 NEXT
  355. 4290 DATA "upper","left","front","right","back","down"
  356. 4300 FOR FACE=1 TO 6'                If you have a cube that's used frequently,
  357. 4310     READ YOURS$(FACE)'          put the six names of its colors as data on
  358. 4320 NEXT '  line 3310 in proper (see line 3270) order. See REMark on line 4160
  359. 4330 DATA "white","orange","blue","red","green","yellow"
  360. 4340 FOR P=1 TO 8'                   Eight cubies surround the center cubie
  361. 4350     READ XOF(P),YOF(P)'         Offsets to locations of middle cubies for
  362. 4360 NEXT '                            each neighboring cubie on the same face
  363. 4370 DATA -1,-3,-1,0,-1,3,0,3,1,3,1,0,1,-3,0,-3
  364. 4380 FOR P=0 TO 8'                   Modify order of printing cubies of each
  365. 4390     READ XOP(P)'                face so that none of the lettered face
  366. 4400 NEXT '                          labels are overwritten. See line 1615.
  367. 4410 DATA 1,2,3,8,0,4,7,6,5
  368. 4420 FOR FA=1 TO 6'                  Six faces
  369. 4430     READ XBL(FA),YBL(FA)'       Locations of labels in WIDTH 40 mode
  370. 4440 NEXT
  371. 4450 DATA 2,4,13,3,4,19,13,19,13,27,17,17
  372. 4460 FOR FA=1 TO 6'                  Six faces
  373. 4470     READ REL(FA),RELY(FA)'      Offsets from old to new locations of the
  374. 4480 NEXT '                            middle cubies of each face
  375. 4490 DATA 1,2,3,0,3,2,3,4,3,6,5,2
  376. 4500 FOR F=1 TO 6'                   Six faces
  377. 4510     READ X(F),Y(F)'             Locations of middle cubies for each face
  378. 4520 NEXT
  379. 4530 DATA 2,14,6,4,6,14,6,24,6,34,10,14
  380. 4540 FOR F=1 TO 6'                   Six faces
  381. 4550     READ OC$(F)' Codes with array indexes to outer circle around each face
  382. 4560 NEXT
  383. 4570 DATA "21514131","17376753","15476123","13576333","11276543","25354555"
  384. 4580 FOR DMI=1 TO 9'                 Nine recognized commands
  385. 4590     READ DM$(DMI)'              Valid display types and other commands
  386. 4600 NEXT
  387. 4610 DATA CODE,FACE,COLOR,LABEL,NEW,BIG,LIST,HELP,SKIP
  388. 4620 DIRECTION$(0)="clockwise":DIRECTION$(2)="counterclockwise"
  389. 4630 T$="ULFRBD"'                    Valid twist requests
  390. 4640 TWISTSSOFAR$(0)="The list of twists so far :"
  391. 4650 TITLE$=SPACE$(7)+"RUBIK'S CUBE SIMULATOR"+SPACE$(7)
  392. 4660 RETURN
  393. 4670 '*******************   INITIALIZE VARIABLES   ****************************
  394. 4680 DEF SEG=0'                                      Is color monitor present?
  395. 4690 IF (PEEK(&H410) AND &H30)<>&H30 THEN CLRMON=-1' If so, set clrmon flag on
  396. 4700 DM=1'                                           Set display type for faces
  397. 4710 LABEL=-1'                                       Turn label flag on
  398. 4720 RETURN
  399. 4730 '*******************   TITLE PAGE   **************************************
  400. 4740 IF CLRMON THEN COLOR 1,4:WIDTH 40:K=1 ELSE WIDTH 80:K=21
  401. 4750 CLS:LOCATE 3,2+K:PRINT TITLE$
  402. 4760 LOCATE 6,15+K:PRINT "PC MAGAZINE"
  403. 4770 LOCATE ,15+K:COLOR 7:PRINT "March, 1982"
  404. 4780 LOCATE 24,19+K:PRINT "press the space bar";
  405. 4790 IF INKEY$<>" " THEN 4790
  406. 4800 COLOR 7,0
  407. 4810 RETURN
  408. 4820 '*******************   INPUT A COLOR FOR EACH FACE   *********************
  409. 4830 CLS
  410. 4840 LOCATE 2,7+K
  411. 4850 K$="*** COLORING THE CUBE ***"
  412. 4860 'Is color monitor present?
  413. 4870 IF CLRMON THEN 4940
  414. 4880 'For those using a monochrome monitor
  415. 4890 PRINT K$
  416. 4900 LOCATE 9,K+6
  417. 4910 PRINT "(The name of each color":PRINT SPC(11+K)"should begin with a":
  418. 4920 PRINT SPC(16+K)"different letter.)":GOTO 5140
  419. 4930 'For those using a color monitor
  420. 4940 FOR L=1 TO 25
  421. 4950     COLOR (L MOD 7)+1
  422. 4960     PRINT MID$(K$,L,1);
  423. 4970 NEXT
  424. 4980 LOCATE 4,4
  425. 4990 FOR C=1 TO 7'               Print a block of color and it's assigned number
  426. 5000     COLOR ,C
  427. 5010     PRINT "     ";
  428. 5020     COLOR C,0
  429. 5030     PRINT "---";C;
  430. 5040     PRINT SPC(10)
  431. 5050 NEXT
  432. 5060 LOCATE 9,1'                Print coloring directions
  433. 5070 COLOR 1,4
  434. 5080 PRINT "Choose each face's color by entering the";
  435. 5090 PRINT "appropiate number from the list above, ";
  436. 5100 COLOR 0,2
  437. 5110 PRINT "or just press [RETURN] for each face and";
  438. 5120 PRINT "the computer will choose the colors.    "
  439. 5130 ' For everybody
  440. 5140 LOCATE 15,K
  441. 5150 COLOR 23,0:PRINT "Enter";
  442. 5160 COLOR 7:PRINT " a color for each face:"
  443. 5170 PRINT
  444. 5180 FOR FACE=1 TO 6
  445. 5190     LOCATE FACE+16,15+K:COLOR 0,7:PRINT USING " \    \";PLACE$(1,FACE);
  446. 5200     COLOR 7,0:INPUT ;" ";PLACE$(2,FACE)'  Semicolon before input promt...
  447. 5210     IF CLRMON THEN 5250'                  ...suppresses the usual linefeed
  448. 5220     IF PLACE$(2,FACE)="" THEN PLACE$(2,FACE)=YOURS$(FACE)'See REMarks from lines 3280-3300 to name colors by default (null input) for frequently used cube
  449. 5230     GOTO 5300
  450. 5240 'Again for those using color
  451. 5250     IF PLACE$(2,FACE)="" THEN BR(FACE)=FACE:GOTO 5280                               ELSE BR(FACE)=VAL(PLACE$(2,FACE))
  452. 5260     IF BR(FACE)<1 OR BR(FACE)>7 THEN LOCATE ,26:PRINT SPC(14):GOTO 5190
  453. 5270     IF ASC(PLACE$(2,FACE))<56 THEN PLACE$(2,FACE)=MID$(PLACE$(2,FACE),2)
  454. 5280     COLOR 7,0:LOCATE ,24:PRINT "= ";'        Print `=' over question mark
  455. 5290     COLOR 0,BR(FACE):PRINT PLACE$(2,FACE)+"     " 'Print name and block of
  456. 5300 NEXT '                                                      selected color
  457. 5310 'And finally, again for everybody
  458. 5320 COLOR 7,0'                            Normalize color and
  459. 5330 LOCATE 15,K:PRINT "*Chosen ";'        Write over blinking prompt
  460. 5340 LOCATE 9,K'                           This writes over coloring directions                                   front  ?
  461. 5350 COLOR 1,4
  462. 5360 PRINT " Check each face and its chosen color. ";
  463. 5370 COLOR 7,0
  464. 5380 PRINT SPC(79)" ";
  465. 5390 LOCATE 11,K
  466. 5400 COLOR 5,2
  467. 5410 PRINT "Press the spacebar to start over... or,";
  468. 5420 COLOR ,0
  469. 5430 PRINT SPC(79)" ";
  470. 5440 LOCATE 13,K
  471. 5450 COLOR 4,6
  472. 5460 PRINT "if everything is oaky press the `g' key."
  473. 5470 COLOR 7,0
  474. 5480 G$=INKEY$
  475. 5490 IF G$=" "THEN 4830
  476. 5500 IF G$<>"G" AND G$<>"g" THEN 5480
  477. 5510 RETURN
  478. 5520 END
  479.  key."
  480. 5470 COLOR 7,0
  481. 5480 G$=INKEY$
  482. 5490 IF